package com.kalian.web;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kalian.client.UserClient;
import com.kalian.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("order")
public class OrderController {
    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    UserClient userClient;

    @GetMapping("test")
    public Page<User> test(@RequestParam int pageNum,@RequestParam int pageSize, @RequestParam(defaultValue = "")String input){
        //String url="http://userservice/user/page?pageNum="+pageNum+"&pageSize="+pageSize;
        return userClient.test(pageNum,pageSize,input);
    }

    @GetMapping("delById")
    public void delById(@RequestParam int id){
        //String forObject = restTemplate.getForObject("http://userservice/user/del?id=" + id, String.class);
        userClient.del(id);
    }

    @PostMapping("save")
    public void save(@RequestBody User user){
        //restTemplate.getForObject("http://userservice/user/add/" + user, String.class);
        userClient.add(user);
    }


}
